package com.konjac.controller;

import com.konjac.dto.LoginDto;
import com.konjac.pojo.ServiceState;
import com.konjac.pojo.User;
import com.konjac.service.UserService;
import com.konjac.service.impl.UserServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController

public class SignInController {

    @RequestMapping("/signIn")
    @ResponseBody
    public ServiceState signIn(@RequestBody LoginDto loginDto) {
        ServiceState serviceState = new ServiceState();
        UserServiceImpl userService = new UserServiceImpl();
        System.out.println(loginDto.getUserName()+" "+loginDto.getPassword());
        try {
            serviceState = userService.signIn(loginDto.getUserName(),loginDto.getPassword());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return serviceState;
    }
}
